from distutils.core import setup
import os, fnmatch
import imp

def find_package_data_files(directory):
    for root, dirs, files in os.walk(directory):
        for basename in files:
            if fnmatch.fnmatch(basename, '*'):
                filename = os.path.join(root, basename)
                if filename.find('/.svn') > -1:
                    continue
                yield filename #.replace('cf/', '', 1)

# Check that the dependencies are met
for _module in ('netCDF4', 'numpy'):
    try:
        imp.find_module(_module)
    except ImportError as error:
        raise ImportError, "Missing dependency. %s" % error
#--- End: for

version   = '0.9.6'
etc_files = [f for f in find_package_data_files('cfunits/etc')]
doc_files = [f for f in find_package_data_files('cfunits/docs')]

#print man_files
setup(name = "cfunits",
      version      = version,
      description  = "A python interface to UNIDATA's Udunits-2 package with CF extensions",
      author       = "David Hassell",
      author_email = "d.c.hassell at reading.ac.uk",
      url          = "http://code.google.com/p/cfunits-python",
      download_url = "http://code.google.com/p/cfunits-python/downloads/list",
      platforms    = ["any"],
      license      = ["OSI Approved"],
      keywords     = ['cf', 'numpy','netcdf','data','science','network','oceanography','meteorology','climate'],
      classifiers  = ["Development Status :: 3 - Alpha",
                      "Intended Audience :: Science/Research", 
                      "License :: OSI Approved", 
                      "Topic :: Software Development :: Libraries :: Python Modules",
                      "Topic :: System :: Archiving :: Compression",
                      "Operating System :: OS Independent"],
      packages     = ['cfunits'],
      package_data = {'cfunits': doc_files,
                      'cfunits': etc_files,
                      },
      requires     = ['netCDF4 (>=0.9.3)', 'numpy (>=1.4)']
  )
